package com.gh.cloud.feign;

import feign.Feign;
import feign.gson.GsonDecoder;

import java.util.List;

/**
 * @author: guohao
 * @date: 2021-02-02 11:45
 **/
public class Test {
    public static void main(String[] args) {
        /**
         *  Feign.target() 实际上是创建了一个 GitHub 的动态代理。通过这个代理来访问url，获取到结果后，包装成对象返回.
         */
        GitHub github = Feign.builder()
                .decoder(new GsonDecoder())
                .target(GitHub.class, "https://api.github.com");

        List<Contributor> contributors = github.contributors("OpenFeign", "feign");
        for (Contributor contributor : contributors) {
            System.out.println(contributor);
        }
    }

}
